import request from '../utils/request'
import store from '../store'
const getChannelList = () => request({
  method: 'GET',
  url: '/v1_0/user/channels',
  headers: {
    Authorization: 'Bearer ' + store.state.token
  }
})
const getArticlesList = (id, timestamp = Date.now() + '') => request({
  method: 'GET',
  url: '/v1_0/articles',
  params: {
    channel_id: id,
    timestamp
  }
})
// 文章不感兴趣
const delArticlesItem = (target) => request({
  method: 'POST',
  url: '/v1_0/article/dislikes',
  data: {
    target: target
  },
  headers: {
    Authorization: 'Bearer ' + store.state.token
  }
})
// 文章举报
const ArticlesPost = (id, type, remark) => request({
  method: 'POST',
  url: '/v1_0/article/reports',
  headers: {
    Authorization: 'Bearer ' + store.state.token
  },
  data: {
    target: id,
    type,
    remark: type === 0 ? remark : remark || null
  }
})
// 获取所有频道的接口
const getPinDaoList = () => request({
  url: '/v1_0/channels'
})
// 更新用户已选
const gengXinList = (channels) => request({
  method: 'PUT',
  url: '/v1_0/user/channels',
  data: {
    channels
  }
})
// 联想菜单 LianxiangMenu
const LxMenu = (q) => request({
  url: '/v1_0/suggestion',
  params: {
    q
  }
})
export { getChannelList, getArticlesList, delArticlesItem, ArticlesPost, getPinDaoList, gengXinList, LxMenu }
